<?php
Shop::register('css/shop.css');
$this->breadcrumbs=array(
		Shop::t('Orders')=>array('index'),
		$model->order_id,
		);

?>
<h2> <?php echo Shop::t('Order') ?> #<?php echo $model->order_id; ?></h2>

<h3> <?php echo Shop::t('Ordering Info'); ?> </h3>

<?php $this->widget('zii.widgets.CDetailView', array(
			'data'=>$model,
			'attributes'=>array(
				'order_id',
				array(
                    'label' => 'User',
                    'value' => $model->getUser()->username
                ),
                array(
                    'label' => Shop::t('Ordering date'),
                    'value' => date('d. m. Y G:i',$model->created_time)
                ),
				array(
                    'label' => 'Status',
                    'value' => $model->getStatusName()
                ),
                array(
                    'label' => 'Total Price',
                    'value' => $model->total_price
                )
				),
			)); ?>

<h3> <?php echo Shop::t('Product Info'); ?> </h3>

<?php $this->widget('zii.widgets.CDetailView', array(
			'data'=>$model,
			'attributes'=>array(
				array(
                    'label' => 'Product name',
                    'value' => Product::model()->findByPk($model->product_id)->name
                ),
                array(
                    'label' => 'Distributor',
                    'value' => Users::model()->findByPk($model->distributor_id)->full_name
                ),
				),
			)); ?>

<h3> <?php echo Shop::t('Customer Info'); ?> </h3>

<?php $this->widget('zii.widgets.CDetailView', array(
			'data'=>$model->user,
			'attributes'=>array(
				'email',
				),
			)); ?>

<div class="summary_delivery_address">
<h3> <?php echo Shop::t('Delivery address'); ?> </h3>
<?php $this->widget('zii.widgets.CDetailView', array(
			'data'=>$model->deliveryAddress,
			'attributes'=>array(
				'firstname',
				'lastname',
				'address',
				'province',
				),
			)); ?>
</div>

<div class="summary_billing_address">
<h3> <?php echo Shop::t('Billing address'); ?> </h3>
<?php $this->widget('zii.widgets.CDetailView', array(
			'data'=>$model->billingAddress,
			'attributes'=>array(
				'firstname',
				'lastname',
				'address',
				'province',
				),
			)); ?>
</div>

<?php 
$this->renderPartial('/paymentMethod/view', array(
	'model' => $model->paymentMethod)); 
$this->renderPartial('/shippingMethod/view', array(
	'model' => $model->shippingMethod)); 
?>
<div class="buttons"> 
    <?php
    if ($model->status == 2 || $model->status == 3)
        echo CHtml::link(Shop::t('Checkout'), array(
                '//shop/order/checkout', 'id' => $model->order_id )); 
    ?>
</div>
<div style="clear:both;"> </div>

<div class="buttons"> 
<?php

echo CHtml::link(Shop::t('Delivery slip'), array(
			'//shop/order/slip', 'id' => $model->order_id )); 

echo CHtml::link(Shop::t('Invoice'), array(
			'//shop/order/invoice', 'id' => $model->order_id)); 

echo CHtml::link(Shop::t('Back to Orders'), array(
			'//shop/order/admin')); 

?>
</div>
